<template>
    <div class="container">
        <div class="content manpower">
              <ul class="react-sticky" id="oul">
                  <li :class="toogleindex === 0 ? 'active' : ''" @click=" getuser(0)">1 tabs</li>   
                  <li :class="toogleindex === 1 ? 'active' : ''" @click="getuser(1)">2 tabs</li> 
                  <li :class="toogleindex === 2 ? 'active' : ''" @click=" getuser(2)">3 tabs</li> 
                  <li :class="toogleindex === 3 ? 'active' : ''" @click="getuser(3)">4 tabs</li> 
                  <li :class="toogleindex === 4 ? 'active' : ''" @click="getuser(4)">5 tabs</li> 
                  <span class="line" ref="boxborder" id="boxborder"></span>
              </ul>
              <!-- <div></div> -->
        </div>
        <item-footer/>
    </div>
</template>
<script>
// import { setInterval, clearInterval } from 'timers';
// import { getToday ,getToMonth,getPreMontAllDate, getPreMonth } from '@/utils/date'
export default {
    name:"manpower",
    data() {
       return {
           toogleindex:0,
           flag:true
       }
    },
    components:{
        
    },
    computed:{},
    mounted(){
        // console.log(getToday())
        // console.log(getToMonth())
        // console.log(getPreMontAllDate(2))
        // console.log(getPreMonth('2019-07-16',12).slice(0,7))
    },
    methods:{
        getuser(num){
            var timer
            var btn = document.getElementById('boxborder');
            var oul = document.getElementById('oul').children[0];
            if(this.flag){
                this.flag = false;
                var btn = document.getElementById('boxborder');
                var btnTop = document.getElementById('boxborder').offsetTop;
                if(num > this.toogleindex){
                    timer = setInterval( ()  => {
                        if(btnTop  >= this.toogleindex * oul.clientHeight){
                            clearInterval(timer)
                            this.flag = true;
                        }else{
                            btnTop+=4
                            btn.style.top = btnTop + 'px';
                        }
                    },1)
                }else{
                    timer = setInterval( ()  => {
                        if(btnTop <= this.toogleindex * oul.clientHeight){
                            clearInterval(timer)
                            this.flag = true;
                        }else{
                            btnTop-=4
                            btn.style.top = btnTop + 'px';
                        }
                    },1)
                }
                this.toogleindex = num
            }  
        },
        changeHandler(cur) {
            // console.log('Z和i')
            this.current = cur;
            // console.log(cur)
        }
    }
}
</script>
<style lang="less">
.react-sticky{
    width:100px;
    margin:100px auto;
     position: relative;
    li{
        background: #fff;
        height:50px;
       
        text-align: center;
        line-height: 50px;
        border-right:1px solid transparent;
        &.active{
            color:#108ee9;
            // border-right: 1px solid #108ee9;
            box-sizing: border-box;
            // transition: 1s all linear;
        }
        
    }
    .line{
          display: block;
          position: absolute;
          right:0;
          top:0;
          width: 2px;
          height:50px;
          background:#108ee9;
        }
    
}
</style>
